<template>
  <view class="address_edit">
    <u-navbar title="" @rightClick="rightClick" :autoBack="true">
      <template #center>
        <view class="center_column flex column">
          <span class="tittle_info">地址修改</span>
        </view>
      </template>
      <template #right>
        <view class="pbulish_btn">保存 </view>
      </template>
    </u-navbar>
    <!-- 占位符 -->
    <view style="height: 88rpx"></view>
    <view class="address_edit_info">
      <view class="address_detail">详细地址</view>
      <u--textarea
        style="margin-top: 28rpx"
        height="190"
        v-model="userInfo.address"
        placeholder="详细信息街道门牌信息等"
        maxlength="200"
      ></u--textarea>
    </view>
  </view>
</template>
<script setup>
import { userApi } from "../../api";

onLoad((options) => {
  // console.log("options", options.address);
  userInfo.value.address = options.address;
});
const userInfo = ref({
  nickname: "",
  address: "",
  email: "",
  avatar: ""
});
const rightClick = () => {
  if (userInfo.value.address == "") {
    uni.showToast({
      title: "请输入地址再保存",
      icon: "none"
    });
    return;
  }
  userApi.userinfoedit(userInfo.value).then((res) => {
    if (res.code == 1) {
      uni.showToast({
        title: res.msg,
        icon: "none"
      });
      // getUserInfo();
      uni.navigateBack();
    }
    if (res.code == 0) {
      uni.showToast({
        title: res.msg,
        icon: "none"
      });
    }
  });
};
</script>
<style lang="scss" scoped>
.address_edit_info {
  padding: 40rpx 32rpx;
  box-sizing: border-box;
  height: 100%;
  width: 100%;
  margin-top: 88rpx;
  .address_detail {
    height: 44rpx;
    font-size: 32rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.87);
    line-height: 40rpx;
  }
}
.center_column {
  display: flex;
  align-items: center;
  justify-content: center;
  .tittle_info {
    font-size: 34rpx;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: #000000;
    line-height: 50rpx;
  }
  span {
    font-size: 20rpx;
    font-family: PingFang SC-Medium, PingFang SC;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.38);
    line-height: 22rpx;
  }
}
.pbulish_btn {
  width: 96rpx;
  height: 48rpx;
  line-height: 48rpx;
  background: #306eff;
  border-radius: 46rpx 46rpx 46rpx 46rpx;
  opacity: 1;
  font-size: 24rpx;
  font-family: PingFang SC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  text-align: center;
}
</style>